﻿@using System.Threading.Tasks
@using Abp.Application.Services.Dto
@using MyCompanyName.AbpZeroTemplate.Authorization
@using MyCompanyName.AbpZeroTemplate.Web.Areas.AppAreaName.Models.Tenants
@using MyCompanyName.AbpZeroTemplate.Web.Areas.AppAreaName.Startup
@model TenantIndexViewModel
@{
    ViewBag.CurrentPageName = AppAreaNamePageNames.Host.Tenants;
}
@section Styles
    {
    <link rel="stylesheet" abp-href="/view-resources/Areas/AppAreaName/Views/_Bundles/tenant-list.css" asp-append-version="true" />
}

@section Scripts
    {
    <script abp-src="/view-resources/Areas/AppAreaName/Views/_Bundles/tenant-index-libs.js" asp-append-version="true"></script>
}

<div class="kt-subheader kt-grid__item">
    <div class="kt-subheader__main">
        <h3 class="kt-subheader__title">
            <span>@L("Tenants")</span>
        </h3>
        <span class="kt-subheader__separator kt-subheader__separator--v"></span>
        <span class="kt-subheader__desc">
            @L("TenantsHeaderInfo")
        </span>
    </div>
    <div class="kt-subheader__toolbar">
        <div class="kt-subheader__wrapper">
            @if (IsGranted(AppPermissions.Pages_Tenants_Create))
            {
                <button id="CreateNewTenantButton" class="btn btn-primary"><i class="fa fa-plus"></i> @L("CreateNewTenant")</button>
            }
        </div>
    </div>
</div>

<div class="kt-content">
    <div class="kt-portlet">
        <div class="kt-portlet__body">
            <div class="kt-form">
                <div id="TenantsFormFilter">
                    <div class="row mb-4">
                        <div class="col-xl-6">
                            <label for="TenantsTableFilter">@L("TenantNameOrTenancyCode")</label>
                            <div class="input-group">
                                <input id="TenantsTableFilter" class="form-control" type="text" value="@ViewBag.FilterText" placeholder="@L("SearchWithThreeDot")" aria-describedby="basic-addon2">
                                <span class="input-group-btn">
                                    <button id="GetTenantsButton" class="btn btn-primary" type="submit"><i class="flaticon-search-1" aria-label="@L("Search")"></i></button>
                                </span>
                            </div>
                        </div>
                        <div class="col-xl-6">
                            <label for="EditionDropdown">@L("Edition")</label>
                            @Html.DropDownList("EditionDropdown", Model.EditionItems.Select(i => i.ToSelectListItem()), new { @class = "form-control edited" })
                        </div>
                    </div>
                    <div class="row mb-4">
                        <div class="col-xl-6">
                            <div class="kt-checkbox-list">
                                <label class="kt-checkbox">
                                    <input type="checkbox"
                                           id="TenantsTable_SubscriptionEndDateRangeActive"
                                           name="SubscriptionEndDateRangeActive"
                                           value="true">
                                    @L("SubscriptionEndDate")
                                    <span></span>
                                </label>
                            </div>
                            <input type="text" name="SubscriptionEndDateRange" class="form-control date-range-picker">
                        </div>
                        <div class="col-xl-6">
                            <div class="kt-checkbox-list">
                                <label class="kt-checkbox">
                                    <input type="checkbox"
                                           id="TenantsTable_CreationDateRangeActive"
                                           name="CreationDateRangeActive"
                                           value="true">
                                    @L("CreationTime")
                                    <span></span>
                                </label>
                            </div>
                            <input type="text" name="CreationDateRange" class="form-control date-range-picker">
                        </div>
                    </div>
                    <div class="row mb-4">
                        <div class="col-xl-12 text-right">
                            <button name="RefreshButton" class="btn btn-primary"><i class="fa fa-sync"></i> @L("Refresh")</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="align-items-center">
                <table id="TenantsTable" class="display table table-striped table-bordered table-hover dt-responsive nowrap">
                    <thead>
                        <tr>
                            <th></th>
                            <th>@L("Actions")</th>
                            <th>@L("TenancyCodeName")</th>
                            <th>@L("Name")</th>
                            <th>@L("Edition")</th>
                            <th>@L("SubscriptionEndDateUtc")</th>
                            <th>@L("Active")</th>
                            <th>@L("CreationTime")</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
